
from tortoise import fields
from app.models.base.base import BaseModel
from enum import Enum

class MethodType(str, Enum):
    """HTTP请求方法枚举"""
    GET = "GET"
    POST = "POST"
    PUT = "PUT"
    DELETE = "DELETE"
    PATCH = "PATCH"
    HEAD = "HEAD"
    OPTIONS = "OPTIONS"


## API接口模型
class Api(BaseModel):
    """API接口模型"""
    path = fields.CharField(max_length=100, description="API路径", index=True)
    method = fields.CharEnumField(MethodType, description="请求方法", index=True)
    summary = fields.CharField(max_length=500, description="请求简介", index=True)
    tags = fields.CharField(max_length=100, description="API标签", index=True)

    class Meta:
        table = "api"
        table_description = "API接口表"
        
    def __str__(self):
        return f"Api(id={self.id}, method={self.method}, path={self.path})"

